<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/product"%>
<head>
</head>
<form class="mainForm" name="productListForm" method="post" id="productListForm" action="${ctxPath}/inventory/inventory.html">
	<c:set var="editURLPath"	value="/inventory/inventory.html?doAction=edit&from=list" scope="page" />
	<div class="top clearfix">
		<ul class="tab">
			<li class="curr"><span><fmt:message key="menu.inventoryList"/></span></li>
		</ul>
		<%@include file="/common/pagingOnlyTop.jsp"%>
	</div>
	<div class="data">		
		<c:set var="checkAll">
			<input type="checkbox" name="allbox" onclick="checkAll(this.form)"	class="checkbox" />
		</c:set>
		<c:set var="isNeedTopPaging" value="true"/>
		
		<table id="product" width="100%" border="0" cellspacing="0"  cellpadding="0" class="list_table">
			<tr>
				<th class='sortable ${(productSearchCriteria.orderby eq 3)?"sorted order1":((productSearchCriteria.orderby eq 4)?"sorted order2":"")}'>
					<a onclick="sortField(this,3,4)"><fmt:message key="product.productName" /></a>
				</th>
				<th style="width: 80px;"> 
					<span><fmt:message key="productSku.imageUrl" /></span>
				</th>
				<th style="width: 120px;"><fmt:message key="productSku.productSkuCodeAndOption" /></th>
				<th style="width: 160px;"><fmt:message key="inventoryList.stockInfo" /></th>
				<th style="width: 120px;"><fmt:message key="inventory.quantityOnHand" /></th>
				<th style="width: 100px;"><fmt:message key="inventory.reorderMinimnm" /></th>
				<th style="width: 60px;"><fmt:message key="inventory.log" /></th>
			</tr>
			<c:forEach var="product" items="${productList}" varStatus="status">
				<tr  class="${(status.index%2==0)?'even':'odd'}">
					<td>
						<b>${product.productName}</b>
						<c:if test="${product.productKind == 2}">
							&nbsp;【<fmt:message key="product.package"/>】 
						</c:if>
					</td>
					<td>
						<ul class="${fn:length(product.productSkus)>1?'ul2':'ul1'}">
							<c:forEach items="${product.productSkus}" var="sku">
								<li>
									<img src="${mediaPath}/<product:imageSrc  url="${sku.imageUrl}" sizeType="s0"/>" onerror="this.src=__defaultImage_s0" width="58" height="58"/>
								</li>
							</c:forEach>
						</ul>	
					</td>
					<td>
						<ul class="${fn:length(product.productSkus)>1?'ul2':'ul1'}">
							<c:forEach items="${product.productSkus}" var="sku">
								<li>
									${sku.productSkuCode}
									<dl class="property_02 clearfix">
										<ul class="clearfix">
											<c:forEach items="${sku.productSkuOptionValues}" var="productSkuOptionValue">
												<product:skuOptionValue skuOptionValue="${productSkuOptionValue.skuOptionValue}"/>
											</c:forEach>
										</ul>
									</dl>		
								</li>
							</c:forEach>
						</ul>	
					</td>
					<td>
						<ul class="${fn:length(product.productSkus)>1?'ul2':'ul1'}">
							<c:forEach items="${product.productSkus}" var="sku">
								<li>
									<div id="inventoryInfo_${sku.productSkuId}">
										<%@include file="inventoryInfo.jsp" %>
									</div>
								</li>
							</c:forEach>
						</ul>	
					</td>
					<td>
						<ul class="${fn:length(product.productSkus)>1?'ul2':'ul1'}">
							<c:forEach items="${product.productSkus}" var="sku">
								<li>
									<input type="text" id="quantityOnHand_${sku.productSkuId}" name="quantityOnHand" value="${sku.inventory.quantityOnHand}" class="inputtxt" style="width:50px;">
								</li>
							</c:forEach>
						</ul>	
					</td>
					<td>
						<ul class="${fn:length(product.productSkus)>1?'ul2':'ul1'}">
							<c:forEach items="${product.productSkus}" var="sku">
								<li>
									<input type="text" id="reorderMinimnm_${sku.productSkuId}" name="reorderMinimnm" value="${sku.inventory.reorderMinimnm}" class="inputtxt" style="width:50px;">	
								</li>
							</c:forEach>
						</ul>	
					</td>
					<td>
						<ul class="${fn:length(product.productSkus)>1?'ul2':'ul1'}">
							<c:forEach items="${product.productSkus}" var="sku">
								<li>
									<span class="view"></span>
									<a href="javascript:void(0)" onclick="showAuditLog(${sku.productSkuId})">
										<fmt:message key="inventory.log.view"/>
									</a>	
								</li>
							</c:forEach>
						</ul>	
					</td>
				</tr>
			</c:forEach>
			<c:if test="${empty productList}">
				<tr>
					<td colspan="7" style="text-align: center"><fmt:message
							key="inventoryList.empty" /></td>
				</tr>
			</c:if>
		</table>					
		<%@include file="/common/pagingOnly.jsp" %>
	</div>
</form>
<%--------保存查询条件 -------%>
<%@include file="inventorySearchCriteriaStorage.jspf"%>

<script type="text/javascript">
$j(document).ready(function () {
	highlightTableRows("product");
	
	<c:forEach	items="${productList}" var="product" varStatus="status">
		<c:forEach items="${product.productSkus}" var="sku">
			var allq = ${empty sku.inventory.allocatedQuantity?0:sku.inventory.allocatedQuantity};
			var qoh = ${empty sku.inventory.quantityOnHand?0:sku.inventory.quantityOnHand};
			var params = {"productSkuId":${sku.productSkuId},"allocatedQ":allq,"quantityOh":qoh};
			$j('#quantityOnHand_${sku.productSkuId}').bind('blur',params,updateOnhand).attr("tabindex",${status.index+1}).bind('keyup',params,updateOnhand).attr("tabindex",${status.index+1});
			$j('#reorderMinimnm_${sku.productSkuId}').bind('blur',{"productSkuId":${sku.productSkuId}},updateReorderMinimnm).attr("tabindex",${status.index+1}).bind('keyup',{"productSkuId":${sku.productSkuId}},updateReorderMinimnm).attr("tabindex",${status.index+1});
		</c:forEach>
	</c:forEach>
});
</script>
